#include <stdio.h>
#define SIZE 10

int arr[SIZE],top;

void top_value()
{
	if(top == 0)
	{
		printf("Error,the stack is empty!\n");
		return;
	}
	printf("%d\n",arr[top - 1]);
}

void push()
{
	int t;
	if(top == 10)
	{
		printf("Error,the stack is full!\n");
		return;
	}
	scanf("%d",&t);
	arr[top++] = t;
}

void pop()
{
	if(top == 0)
	{
		printf("Error,the stack is empty!\n");
		return;
	}
	printf("%d\n",arr[--top]);
}

void menu()
{
	printf("1.top\t2.pop\n");
	printf("3.push\t4.exit\n");
	printf("please enter:");
}

int main()
{
	int selection;
	top = 0;
	while(1) {
		menu();
		scanf("%d",&selection);
		switch(selection) {
		case 1:
			top_value();
			break;
		case 2:
			pop();
			break;
		case 3:
			push();
			break;
		case 4:
			return 0;
		}
	}
	return 0;
}
